#include "friend.pb.h"
#include "mprpcapplication.h"
#include <iostream>
#include <memory>

int main(int argc, char **argv)
{
    MprpcApplication::Init(argc, argv);
    std::shared_ptr<MprpcChannel> p = std::make_shared<MprpcChannel>();
    fixbug::FriendServiceRpc_Stub stub(p.get());
    fixbug::GetFriendListRequest request;
    request.set_name("zhang san");
    request.set_pwd("123456");

    fixbug::GetFriendListResponse response;
    MprpcController controller;
    stub.GetFriendList(&controller, &request, &response, nullptr);
    if (controller.Failed())
    {
        std::cout << controller.ErrorText() << std::endl;
    }
    else
    {
        if (0 == response.result().errcode())
        {
            for (size_t i = 0; i < response.friends_size(); i++)
            {
                std::cout << "friends " << response.friends(i) << std::endl;
            }
        }
        else
        {
            std::cout << "rpc get friend list error:" << response.result().errmsg() << std::endl;
        }
    }

    return 0;
}